<template>
  <el-table
    :data="data"
    style="width: 100%">
    <el-table-column
      label="名称"
      prop="name">
    </el-table-column>
    <el-table-column
      label="类型">
      <template scope="scope">
        <el-tag v-if="scope.row.type==0">公众号</el-tag>
        <el-tag v-if="scope.row.type==1">小程序</el-tag>
      </template>
    </el-table-column>
    <el-table-column label="操作" width="180">
      <template scope="scope">
        <router-link :to="{name:'app',params:{appid:scope.row.id}}" v-if="scope.row.type==1" >
            <el-button @click="setWxid(scope.row.id)"
              size="small">管理</el-button>
        </router-link>
        <router-link :to="{name:'app',params:{appid:scope.row.id}}" v-if="scope.row.type==0" >
          <el-button @click="setWxid(scope.row.id)"
            size="small">管理</el-button>
        </router-link>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  data () {
    return {
      data:[],
      pageParams:[]
    }
  },
  methods:{
    setWxid:function (id) {
      this.$store.commit('SET_WECHATID',{wechatId:id});
      console.log(this.$store.state.auth);
    }
  },
  mounted(){
      this.Api.getWehcat(this.pageParams).then((response)=>{
          this.data=response.data.data;
          this.pageParams=response.data.pageParams;
      });
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
